const Router = require('koa-router');
const jwt = require('koa-jwt')
const {
  secret
} = require('../config');
const router = new Router({
  prefix: '/users'
});
const {
  find,
  findById,
  create,
  deleteUser,
  update,
  login,
  checkOwner
  } = require('../controllers/users');
  
const auth = jwt({secret});
 
router.get('/', auth, find);
router.post('/',create);
router.get('/:id', auth, findById);
router.patch('/:id', auth, checkOwner, update);
router.delete('/:id', auth, deleteUser);
router.post('/login', login);
module.exports = router;
